Ektron Reference |
Ektron's templated server controls use an MVC architecture, which is a common design pattern for user interfaces. MVC consists of a
Model, which stores the state and accesses the application code used by the control; resides in the service layer
View, which renders the data
Controller, which maps action inputs to the model and elements view; also performs the business logic of the UI
Since MVC architecture separates the display layer from the data layer, a designer can work on the styling of the search results page, while a developer focuses on data being rendered.
You can extend the functionality of templated server controls by creating a custom service. For example, you can dynamically replace the content of the search results. You might want to do this to create a profanity filter, or to implement a "blacklist" of replacement terms in search results.
The following image illustrates the location of a custom (passthru) service within MVC architecture.
The passthru service completes these steps.
Use the siteroot/unity.ui.services.config file to map each search type to a service. Below is the section of the file that accomplishes the mapping. By default, the Ektron search controls use ISearch.Service to take in and return data.
Note separate register statements for regular searches, product searches, and user searches.
NOTE: The ISearchController service handles regular content and XML Smart Form searches.
Follow these steps to create your own service and map it to a search type.
1. In Visual Studio, open siteroot/unity.ui.services.config.
2. Update the service registration with a new service name. This example assigns to ISearchService a service named DemoSearchService.
3. In Solution Explorer, right click the AppCode folder and select Add New Item.
4. Select C# Class and give your new service a name.
5. Within the .cs file, insert this statement: using Ektron.Cms.Framework.UI;
6. Assign the name of the service that you are overriding. (Service names are listed in unity.ui.services.config.)
7. Right click the mouse and select Implement Interface > Implement Interface.
8. Several statements like the one below are inserted. They provide inputs to the search service.
9. To create a passthru service, first instantiate the old mock search service.See Also: Creating a Custom Service
10. Inside the Advanced, Basic, GetXmlSearchFieldList and XmlSearch methods, call the old service and pass in the same data. Here is one example.
Now, when you drop inputview and resultsview controls on a page, it
Example 1: Any search returns “fifteen” for a result
Example 2: Replace “Summary” with “Ektron” in all Results
Example 3: Remove First Result
1. Open the site search template page.
2. Within SiteSearchResultsView
tags, insert a set of <itemtemplate>
tags.
3. Within the <itemtemplate>
tags, insert <%# Eval(“QueryText”) %>
4. Within the new.cs file that you created in Procedure for Creating a Custom Service, modify the value of QueryText
. For this example, change the query text to "fifteen." To do this, edit the .cs file, like this.
This example shows how search results may be modified after they are retrieved (that is, on the way back). To do this, edit the .cs file that you created in Procedure for Creating a Custom Service like this.
The above code loops through all results (Results.ForEach
) and replaces "Summary" with "Ektron" in each one.
This example shows how to remove the first search result that is retrieved. To do this, edit the .cs file that you created in Procedure for Creating a Custom Service like this.
Ektron Version 8.5, Doc. Rev. 2.0 (Dec. 2011)
Visit the Ektron Dev Center at http://dev.ektron.com 1–866–4–EKTRON
Ektron Documentation, © 2011 Ektron, Inc.